const initialState = {
  todoList: []
}
function reducer(state = initialState, { type, payload }) {
  switch (type) {
    case 'ADD':
      state.todoList = [payload.value, ...state.todoList]
      break;
    case 'DELETE':
      state.todoList.splice(payload.index, 1)
      break;
  }
  return JSON.parse(JSON.stringify(state))
}

export default reducer